import axios from "axios"
import LocalStorageUtil from "@/common/LocalStorageUtil";

const axiosInstance = axios.create({
	timeout: 100000,
})

axiosInstance.interceptors.request.use((config) => {
	// 如果不是login请求则请求带token认证
	if (config.url != "/login") {
		let token = LocalStorageUtil.get("token");
		config.headers.set("Authorization", token)
	}
	return config
}, (error) => {
	return Promise.reject(error)
})

axiosInstance.interceptors.response.use((respose) => {
	return respose
}, (error) => {
	return Promise.reject(error)
})

export default () => axiosInstance